package interfaz;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;


	public class Niveles extends JFrame {

		private static final long serialVersionUID = 1L;
		private JPanel mainPanel;
		private JButton atrasButton;
		private JButton bajoButton;
		private JButton medioButton;
		private JButton altoButton;
		
		public Niveles() {
			inicializaComponentes();
			pack();
			
			Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	        Dimension frameSize = getSize();
	        setLocation(new Point((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.width) / 2));
		}

		private void inicializaComponentes() {
			GridBagConstraints gridBagConstraints;
			
			mainPanel = new JPanel();
			atrasButton = new JButton();
			bajoButton = new JButton();
			medioButton = new JButton();
			altoButton = new JButton();
			
			setTitle("Link-A-Pix");
			
	   		mainPanel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
		    mainPanel.setMinimumSize(new Dimension(297, 200));
		    mainPanel.setLayout(new GridBagLayout());
		    
		    bajoButton.setText("Nivel bajo");
	        bajoButton.setMnemonic('B');
	        bajoButton.setToolTipText("Empezar juego");
	        bajoButton.setSize(30, 5);
	        bajoButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					cargarDibujoNivelBajoActionPerformed(evt);
				}
			});
	        gridBagConstraints = new GridBagConstraints();
	        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
	        gridBagConstraints.anchor = GridBagConstraints.CENTER;
	        gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	        gridBagConstraints.insets = new Insets(6, 6, 6, 12);
	        mainPanel.add(bajoButton, gridBagConstraints);
			
		    getContentPane().add(mainPanel, BorderLayout.CENTER);
		    
		    
		    
		   medioButton.setText("Nivel medio");
		   medioButton.setMnemonic('M');
		   medioButton.setToolTipText("Empezar juego");
		   medioButton.setSize(30, 5);
		   medioButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					cargarDibujoNivelMedioActionPerformed(evt);
				}
			});
		   
		   gridBagConstraints = new GridBagConstraints();
	       gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
	       gridBagConstraints.anchor = GridBagConstraints.CENTER;
	       gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	       gridBagConstraints.insets = new Insets(6, 6, 6, 12);
	       mainPanel.add(medioButton, gridBagConstraints);
	       
	       
		   altoButton.setText("Nivel alto");
		   altoButton.setMnemonic('A');
		   altoButton.setToolTipText("Empezar juego");
		   altoButton.setSize(30, 5);
		   altoButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					cargarDibujoNivelAltoActionPerformed(evt);
				}
			});
		   
		   gridBagConstraints = new GridBagConstraints();
	       gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
	       gridBagConstraints.anchor = GridBagConstraints.CENTER;
	       gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	       gridBagConstraints.insets = new Insets(6, 6, 6, 12);
	       mainPanel.add(altoButton, gridBagConstraints);
	       
	       
	       
	       
		    
		    
		    
		    atrasButton.setMnemonic('N');
	        atrasButton.setText("Volver");
	        atrasButton.setToolTipText("Volver");
	        atrasButton.addActionListener(new ActionListener() {
	            public void actionPerformed(ActionEvent evt) {
	                atrasButtonActionPerformed(evt);
	            }
	        });
	        gridBagConstraints = new GridBagConstraints();
	        gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
	        gridBagConstraints.gridheight = GridBagConstraints.REMAINDER;
	        gridBagConstraints.anchor = GridBagConstraints.SOUTHEAST;
	        gridBagConstraints.weighty = 1.0;
	        mainPanel.add(atrasButton, gridBagConstraints);
	        
		}

		
		protected void cargarDibujoNivelBajoActionPerformed(ActionEvent evt) {
			this.setVisible(false);
			new NivelBajo().setVisible(true);
		}
		
		protected void cargarDibujoNivelMedioActionPerformed(ActionEvent evt) {
			this.setVisible(false);
			new NivelMedio().setVisible(true);
		}
		protected void cargarDibujoNivelAltoActionPerformed(ActionEvent evt) {
			this.setVisible(false);
			new NivelAlto().setVisible(true);
		}

		protected void atrasButtonActionPerformed(ActionEvent evt) {
			this.setVisible(false);
			new NuevaPartida().setVisible(true);
		}


		
		

}
